<template>
    <div class="home">
        <van-nav-bar
                title="开票信息"
                left-text="返回"
                left-arrow
                border
                fixed
                @click-left="$router.go(-1)"
        />
        <div style="height:50px"></div>
        <div class="title">
            开票信息
        </div>
        <div class="info-line">
            <div>是否允许后付款</div>
            <div>否</div>
        </div>
        <div class="info-line">
            <div>付款方式</div>
            <div>...</div>
        </div>
        <div class="info-line" style="border: none;">
            <div>发票类型</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>开票类型</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>发票名称</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>公司名称</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>税号</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>公司地址</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>公司联系电话</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>开户行</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>开户账号</div>
            <div>...</div>
        </div>
        <div class="info-line">
            <div>是否见票付款</div>
            <div>...</div>
        </div>
        <div style="height: 10vh;"></div>
    </div>
</template>

<script>
// @ is an alias to /src
import headerItem from '@/components/header.vue'
import { getWXUserId } from '@/wxConfig/getWXUserId'

export default {
    name: 'jrBillingInfo',
    data() {
        return {
            userInfoSource: {},
            goodsSource: {},
        };
    },
    components: {
        footerItem,
        headerItem
    },
    methods: {
        getNewsData() {
            let params = {};
            this.$post("/api/workwx/index", params)
                .then(res => {
                    if (res.code == 1) {
                        // this.newsSource = res.data
                        getWXUserId(res.data.js_wx_config, res.data.js_agent_config, this.getUserSuccess)
                    }
                })
                .catch(err => {
                });
        },
        getUserSuccess(id) {
            localStorage.setItem('wx_member_id', id);
            this.getUserInfo();
            this.getUserToken();

        },
        getUserInfo() {
            let params = {
                wx_member_id: localStorage.getItem('wx_member_id'),
                token: localStorage.getItem('token'),
            };
            this.$post("/api/common/index", params)
                .then(res => {
                    if (res.code == 1) {
                        this.userInfoSource = res.data.info
                        this.goodsSource = res.data.goods_list
                    }
                })
                .catch(err => {
                });
        },
        getUserToken() {
            let params = {};
            this.$post("/api/common/get_auth_menu", params)
                .then(res => {
                    if (res.code == 1) {
                        localStorage.setItem('token', res.data.wx_user_id)
                    }else if (res.code == 0) {
                        this.$router.push('/notData')
                    }
                })
                .catch(err => {
                });
        }
    },
    created() {
        this.getNewsData();
        if (process.env.NODE_ENV == "development") {
            this.getUserInfo();
        }
    },

}
</script>
<style scoped lang="less">
.info-line {
    border-bottom: 1px solid #eee;
    margin: 0 16px;
    padding: 13px 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 16px;

    > div:nth-of-type(1) {
        width: 35vw;
        color: #777777;
    }

    > div:nth-of-type(2) {
        flex: 1;
        color: #333;
    }
}

.border-last:last-child {
    border: none;
}
</style>
